#!groovy notifyBuild.groovy
//发送邮件模板
def call(Map kwArgs = [:]) {
    sendEmail(kwArgs)
}

def sendEmail(Map kwArgs = [:]) {

    def buildType = kwArgs['buildType'] ?: 'CI'
    def subjectPrefix = "$buildType"

    def subject = kwArgs['subject'] ?: '''$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS'''
    def content = kwArgs['content'] ?: '''${SCRIPT, template="groovy-html.template"}'''
    def toList = kwArgs['toList'] ?: '123@qq.com,345@qq.com'
    def recipientProviders = kwArgs['recipientProviders'] == [] ? [] : [developers(), requestor(), culprits(), brokenBuildSuspects(), brokenTestsSuspects()]

    emailext(
            subject: "[$subjectPrefix] $subject",
            body: content,
            mimeType: 'text/html; charset=UTF-8',
            from: 'kkk@qq.com',
            recipientProviders: recipientProviders,
            to: toList
    )
}